#include "Pointers.h"

unsigned int* ReadPtrTable(char* szRomName, int iStart,const int iPtrSize)
{

	unsigned int* PtrTempTbl = new unsigned int[iPtrSize];

	FILE *fpRom;
	//abre a trom
	if(!(fpRom = fopen(szRomName, "rb")))
		exit(printf("Unable to open '%s' file.\n", szRomName));

	fseek(fpRom, iStart, SEEK_SET);


	for(int x = 0; x < iPtrSize; x++)
		PtrTempTbl[x] = GetPointer(fpRom);

	fclose(fpRom);

	return PtrTempTbl;
}

int GetPointer(FILE* fp)
{
	return (getc(fp)& 0xFF) | ((getc(fp) << 8) & 0xFF00) + HEADER;
}

int FreePtrTbl(unsigned int* TempTbl)
{
   delete [] TempTbl;

   //fim da makakada
   return 0;	
}
